<template lang="html">
  <div class='box'>
    <mt-header :title="title"></mt-header>
    <img @click='takePhoto' src='../../assets/qrSearch.png'>
  </div>
</template>

<script>
export default {
  data() {
    return {
      title: '唯硒商城'
    }
  },
  created() {
    this.title = this.$route.name
  },
  mounted() {
    window.testResult = this.testResult
  },
  methods: {
    takePhoto () {
      localStorage.removeItem('shareId')
      let u = navigator.userAgent
      let isAndroid = u.indexOf('Android') > -1 || u.indexOf('Linux') > -1; //g
      let isIOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/); //ios终端
      if (isAndroid) {
        //这个是安卓操作系统
        window.android.takePhoto();
      }
      if (isIOS) {
        window.webkit.messageHandlers.takePhoto.postMessage(null)
        //这个是ios操作系统
      }


    },
    testResult (content) {
      this.$router.push({
        path: '/userLogin'
      })
      localStorage.setItem('shareId', content)
      // document.getElementById('result').innerHTML='测试结果:'+ content;
    }
  }
}
</script>

<style lang="less" scoped>
@import '../../assets/fz.less';
@import '../../assets/index/style.css';
.box {
  position: relative;
  img {
    position: absolute;
    right: 10px;
    bottom: 10px;
    width: 20px;
    height: 20px;
  }
}
.mint-header {
  padding: 6.8vw 4.8vw;
  background-color: #048AB9;
  color: white!important;
  .fz(font-size, 40)!important;
}
</style>
